// src/store/userStore.js
import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
    state: () => ({
        userId: 1,
        token: null,
        userInfo: null,
    }),
    actions: {
        setUserId(id) {
            this.userId = id;
        },
        setToken(token) {
            this.token = token;
        },
        setUserInfo(info) {
            this.userInfo = info;
        },
        clearUser() {
            this.userId = null;
            this.token = null;
            this.userInfo = null;
        }
    },
    getters: {
        isAuthenticated: (state) => !!state.userId,
    },
});
